<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">


    <el-form-item label="护理项目编号" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
      <el-form-item label="护理项目名称" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
     <el-form-item label="价格" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
     <el-form-item label="原有数量" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
     <el-form-item label="新增数量" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
    <el-form-item label="总数量" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
    <el-form-item label="服务到期日期" prop="customerid">
      <el-input v-model="dataForm.customerid" placeholder=""></el-input>
    </el-form-item>
   
    
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          remarks: '',
          isdeleted: '',
          customerid: '',
          retreattime: '',
          retreattype: '',
          retreatreason: '',
          auditstatus: '',
          auditperson: '',
          audittime: ''
        },
        
      }
    },
    methods: {
      init (id) {
      

        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/backdown/backdown/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.remarks = data.backDown.remarks
                this.dataForm.isdeleted = data.backDown.isdeleted
                this.dataForm.customerid = data.backDown.customerid
                this.dataForm.retreattime = data.backDown.retreattime
                this.dataForm.retreattype = data.backDown.retreattype
                this.dataForm.retreatreason = data.backDown.retreatreason
                this.dataForm.auditstatus = data.backDown.auditstatus
                this.dataForm.auditperson = data.backDown.auditperson
                this.dataForm.audittime = data.backDown.audittime
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/backdown/backdown/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'id': this.dataForm.id || undefined,
                'remarks': this.dataForm.remarks,
                'isdeleted': this.dataForm.isdeleted,
                'customerid': this.dataForm.customerid,
                'retreattime': this.dataForm.retreattime,
                'retreattype': this.dataForm.retreattype,
                'retreatreason': this.dataForm.retreatreason,
                'auditstatus': this.dataForm.auditstatus,
                'auditperson': this.dataForm.auditperson,
                'audittime': this.dataForm.audittime
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
